From: Daniel Carl <danielcarl@gmx.de>
Date: Sat, 22 Jun 2013 16:51:24 +0000 (+0200)
Subject: Fixed none opening image hints without surrounding link.
X-Git-Url: https://git.owens.tech/assets/lich_lifts_title_slice.png%20%22Lich%20Lifts%22/assets/lich_lifts_title_slice.png%20%22Lich%20Lifts%22/git?a=commitdiff_plain;h=f2527dbd40c69c9a406a8ea2ed4917621a67f81d;p=vimb.git

Fixed none opening image hints without surrounding link.

Image hints could not be opened if they where not within a link, because
clicking an image has no effect here. Now the image src is processed within
the c-layer to open it.
---

diff --git a/Makefile b/Makefile
index 67c4ad6..77aa5e9 100644
--- a/Makefile
+++ b/Makefile
@@ -21,7 +21,7 @@ $(TARGET): $(OBJ)
 	@echo "$(CC) $@"
 	@$(CC) $(OBJ) -o $(TARGET) $(LDFLAGS)
 
-%.o: %.c $(HEAD)
+%.o: %.c %.h src/config.h
 	@echo "${CC} $<"
 	@$(CC) -c -o $@ $< $(CPPFLAGS) $(CFLAGS)
 
diff --git a/src/hints.c b/src/hints.c
index 0ebe2a7..2163120 100644
--- a/src/hints.c
+++ b/src/hints.c
@@ -87,7 +87,9 @@ void hints_create(const char *input, guint mode, const guint prefixLength)
             type = 'i';
         }
 
-        if (mode & HINTS_PROCESS_OPEN) {
+        /* images cant be opened from javascript by click event so we precess
+         * the image source in this file */
+        if (mode & HINTS_PROCESS_OPEN && type != 'i') {
             usage = mode & HINTS_OPEN_NEW ? 'T' : 'O';
         } else {
             usage = 'U';
@@ -164,6 +166,11 @@ static void run_script(char *js)
             a.s = g_strconcat((mode & HINTS_OPEN_NEW) ? ":tabopen " : ":open ", v, NULL);
             command_input(&a);
             g_free(a.s);
+        } else if (mode & HINTS_PROCESS_OPEN) {
+            /* used if images should be opened */
+            a.s = v;
+            a.i = (mode & HINTS_OPEN_NEW) ? VB_TARGET_NEW : VB_TARGET_CURRENT;
+            command_open(&a);
         } else if (mode & HINTS_PROCESS_SAVE) {
             a.s = v;
             a.i = COMMAND_SAVE_URI;
diff --git a/src/hints.h b/src/hints.h
index 52d4220..aee0db0 100644
--- a/src/hints.h
+++ b/src/hints.h
@@ -22,7 +22,7 @@
 
 #include "main.h"
 
-#define HINTS_GET_TYPE(n) ((n) & (HINTS_TYPE_LINK | HINTS_TYPE_IMAGE | HINTS_TYPE_EDITABLE))
+#define HINTS_GET_TYPE(n) ((n) & (HINTS_TYPE_LINK | HINTS_TYPE_IMAGE))
 
 enum {
     HINTS_TYPE_LINK     = 1,
@@ -32,6 +32,7 @@ enum {
     HINTS_PROCESS_YANK  = (1 << 3),
     HINTS_PROCESS_OPEN  = (1 << 4),
     HINTS_PROCESS_SAVE  = (1 << 5),
+    /* additional flag for HINTS_PROCESS_OPEN */
     HINTS_OPEN_NEW      = (1 << 6),
 };